﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using QuickDotNetCore.BaseModels;

namespace QuickDotNetCore.Utils
{
    public class UserPasswordEncryptUtil
    {
        public static string Encrypt(BaseUser userDO)
        {
            return AddSaltEncrypt(userDO.JwtPassword + userDO.JwtID);
        }

        public static bool CheckPassword(BaseUser user, string pwd) {
            Console.WriteLine(user);
            return user.JwtPassword.Equals(AddSaltEncrypt(pwd+user.JwtID));
        }


        private static string AddSaltEncrypt(string data) {
            return EncryptHelper.MD5(data + (data.Length * 44565465L % 27555141));
        }

    }
}
